Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plotting #2338

Draft
wants to merge 10 commits into
base: dev
Choose a base branch
from
Draft

Plotting #2338

wants to merge 10 commits into from

Conversation

codingWhale13
Copy link
Contributor

Description of changes:
This PR addresses #2333 and proposes a plot function that is given a forecast and optionally a time series for reference as well as a bunch of options about how to plot things.

The most interesting part is plotting the different prediction intervals. This now works pretty much as in Forecast.plot. The only major difference is that the lower and upper parts of each prediction interval are created separately to keep the colors true (in Forecast.plot, when plotting a lot of prediction intervals, the colors in the middle get very dark because the alpha of the color gets less with each overlap).

The plot_prob_forecasts used in this tutorial can be replaced by a call to lab.plot. Also, the vertical red line in the tutorial can be created using the train_test_separator parameter.

It might make sense to return the Matplotlib fig and ax so that the user can draw more custom things on top of it (like highlighting the train vs. test data in different colors as is done here).

This proposal would pretty much replace the plot method of Forecast. I think this makes sense because plotting is something separate and the Forecasts would be more lightweight this way.

Biggest caveat at the moment: 150 lines is a lot of code to just plot a forecast. Just providing all the different knobs for the user to choose (like color, legend position etc.) makes things a bit messy but not providing them would render the plot function pretty useless, I think. So, maybe there's an easier way to do this.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codingWhale13 codingWhale13 added enhancement New feature or request discussion This is a discussion thread labels Oct 4, 2022
src/gluonts/lab/plot.py Outdated Show resolved Hide resolved
src/gluonts/lab/plot.py Outdated Show resolved Hide resolved
src/gluonts/lab/plot.py Outdated Show resolved Hide resolved
@kashif
Copy link
Contributor

kashif commented Oct 4, 2022

another potential use case is plotting some of the variates in the multivariate forecasting case... can we get a helper for that too?

@codingWhale13
Copy link
Contributor Author

Thanks for the input, @kashif. 👍 The plot function now supports plotting multivariate forecasts as well. You can choose which variates to plot using the variates_to_plot parameter.

Copy link
Contributor

@jaheba jaheba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My feeling is that we should have many different functions for different tasks. Say I want to compare the output of two models on the same data, then we probably want to plot it differently than just plotting the data for one model.

src/gluonts/lab/__init__.py Outdated Show resolved Hide resolved
@kashif
Copy link
Contributor

kashif commented Oct 10, 2022

Can you check if this will also work for Quantile forecasts?

@codingWhale13
Copy link
Contributor Author

Can you check if this will also work for Quantile forecasts?

It does not. 😄 PR #2352 should fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion This is a discussion thread enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants